import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TCountryPrivilege } from "../../../Message/Db/Tables/TCountryPrivilege";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ECountryPosition } from "../../../Message/Game/ECountryPosition";
import { ESex } from "../../../Message/Public/ESex";
type int = number;
//class CountryConfig
    
    export  class CountryConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (CountryConfig._instance) 
            {
                throw new Error("CountryConfig单利");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_country_privilege.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TCountryPrivilege();
                loc1.position = loc2.position;
                loc1.privilege = StringHelper.getString(loc2.privilege);
                loc1.canResign = loc2.canResign;
                loc1.name = loc2.name;
                loc1.nameEx = loc2.nameEx;
                loc1.titleCode = loc2.titleCode;
                loc1.titleCodeEx = loc2.titleCodeEx;
                loc1.positionDes = StringHelper.getString(loc2.positionDes);
                loc1.privilegeDes = StringHelper.getString(loc2.privilegeDes);
                this._map[loc1.position] = loc1;
            }
            return;
        }

        public getCountryPrivilegeInfo(arg1: int): TCountryPrivilege
        {
            return this._map[arg1];
        }

        public getCountryTabDataProvider(arg1: int): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            var loc4=this._map;
            for(loc2 of loc4) 
            {
                if (loc2.position != ECountryPosition._ECountryPositionQueen) 
                {
                    if (arg1 != ESex._ESexMan) 
                    {
                        loc1.push({"name": loc2.position, "label": loc2.nameEx, "info": loc2});
                    }
                    else 
                    {
                        loc1.push({"name": loc2.position, "label": loc2.name, "info": loc2});
                    }
                    continue;
                }
                if (arg1 == ESex._ESexMan) 
                {
                    loc1.push({"name": loc2.position, "label": loc2.nameEx, "info": loc2});
                    continue;
                }
                loc1.push({"name": loc2.position, "label": loc2.name, "info": loc2});
            }
            loc1.sortOn("name", Array.DESCENDING | Array.NUMERIC);
            return loc1;
        }

        public static get instance(): CountryConfig
        {
            if (CountryConfig._instance == null) 
            {
                CountryConfig._instance = new CountryConfig();
            }
            return CountryConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: CountryConfig;
    }
